This project looks at abortion access in the US over time. I obtain two variables from the Guttmacher Institute: Percentage of patients traveling out of state for abortion, and number of abortion providers in each state. For the final map, I make a GIF of the percentage of patients traveling out of state to obtain care from 2011 to 2020.
In [ ]:
import pandas as pd
import geopandas as gpd
import os
import xarray, rioxarray
import contextily
import seaborn as sns
from pysal.viz import mapclassify as mc
from legendgram import legendgram
import matplotlib.pyplot as plt
import palettable.matplotlib as palmpl
from splot.mapping import vba_choropleth
from shapely.geometry import Polygon
import warnings
warnings.filterwarnings('ignore')
os.chdir('/Users/hanqingye/Desktop/urban_map')
# Providers data
providers = pd.read_csv(os.getcwd()+'/data/no-of-abortion-providers.csv')
providers.head()
Out[ ]:
| measure_name | datum | state_id | state_name | datum_date | first_year | last_year | footnotes | sources | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | No. of abortion providers | 32 | AL | Alabama | 1/1/78 | 1978.0 | NaN | A provider is a hospital, clinic or physician'... | Abortion Incidence and Access to Services in t... |
| 1 | No. of abortion providers | 23 | AK | Alaska | 1/1/78 | 1978.0 | NaN | A provider is a hospital, clinic or physician'... | Abortion Incidence and Access to Services in t... |
| 2 | No. of abortion providers | 39 | AZ | Arizona | 1/1/78 | 1978.0 | NaN | A provider is a hospital, clinic or physician'... | Abortion Incidence and Access to Services in t... |
| 3 | No. of abortion providers | 12 | AR | Arkansas | 1/1/78 | 1978.0 | NaN | A provider is a hospital, clinic or physician'... | Abortion Incidence and Access to Services in t... |
| 4 | No. of abortion providers | 527 | CA | California | 1/1/78 | 1978.0 | NaN | A provider is a hospital, clinic or physician'... | Abortion Incidence and Access to Services in t... |
In [ ]:
# Keep columns needed and change column names
col_names = ['datum', 'state_id', 'state_name', 'datum_date']
providers = providers[col_names]
new_col_names = ['num_providers', 'state_id', 'state_name', 'year']
providers.columns = new_col_names
providers['year'] = pd.to_datetime(providers['year']).dt.year
providers.dtypes
Out[ ]:
num_providers int64 state_id object state_name object year int32 dtype: object
In [ ]:
# Traveling out of state to obtain care data
travel_oos = pd.read_csv(os.getcwd()+'/data/of-residents-obtaining-abortions-who-traveled-out-of-state-for-care.csv')
travel_oos.head()
Out[ ]:
| measure_name | datum | state_id | state_name | first_year | last_year | footnotes | sources | |
|---|---|---|---|---|---|---|---|---|
| 0 | % of residents obtaining abortions who travele... | 17.0 | AL | Alabama | 2011 | NaN | NaN | 1.\tMaddow-Zimet I and Kost K, Even before Roe... |
| 1 | % of residents obtaining abortions who travele... | 11.0 | AK | Alaska | 2011 | NaN | NaN | 1.\tMaddow-Zimet I and Kost K, Even before Roe... |
| 2 | % of residents obtaining abortions who travele... | 2.0 | AZ | Arizona | 2011 | NaN | NaN | 1.\tMaddow-Zimet I and Kost K, Even before Roe... |
| 3 | % of residents obtaining abortions who travele... | 27.0 | AR | Arkansas | 2011 | NaN | NaN | 1.\tMaddow-Zimet I and Kost K, Even before Roe... |
| 4 | % of residents obtaining abortions who travele... | 0.0 | CA | California | 2011 | NaN | NaN | 1.\tMaddow-Zimet I and Kost K, Even before Roe... |
In [ ]:
# Keep columns needed and change column names
col_names = ['datum', 'state_id', 'state_name', 'first_year']
travel_oos = travel_oos[col_names]
new_col_names = ['out_of_state_pct','state_id', 'state_name', 'year']
travel_oos.columns = new_col_names
travel_oos.dtypes
Out[ ]:
out_of_state_pct float64 state_id object state_name object year int64 dtype: object
In [ ]:
# join two dataframes
abortion = pd.merge(providers, travel_oos, on=['state_id', 'state_name', 'year'], how='outer')
abortion.head()
Out[ ]:
| num_providers | state_id | state_name | year | out_of_state_pct | |
|---|---|---|---|---|---|
| 0 | 32.0 | AL | Alabama | 1978 | NaN |
| 1 | 23.0 | AK | Alaska | 1978 | NaN |
| 2 | 39.0 | AZ | Arizona | 1978 | NaN |
| 3 | 12.0 | AR | Arkansas | 1978 | NaN |
| 4 | 527.0 | CA | California | 1978 | NaN |
Geodata¶
In [ ]:
# US states geo data
gdf = gpd.read_file(os.getcwd()+'/data/cb_2018_us_state_500k')
gdf.head()
Out[ ]:
| STATEFP | STATENS | AFFGEOID | GEOID | STUSPS | NAME | LSAD | ALAND | AWATER | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 28 | 01779790 | 0400000US28 | 28 | MS | Mississippi | 00 | 121533519481 | 3926919758 | MULTIPOLYGON (((-88.50297 30.21523, -88.49176 ... |
| 1 | 37 | 01027616 | 0400000US37 | 37 | NC | North Carolina | 00 | 125923656064 | 13466071395 | MULTIPOLYGON (((-75.72681 35.93584, -75.71827 ... |
| 2 | 40 | 01102857 | 0400000US40 | 40 | OK | Oklahoma | 00 | 177662925723 | 3374587997 | POLYGON ((-103.00257 36.52659, -103.00219 36.6... |
| 3 | 51 | 01779803 | 0400000US51 | 51 | VA | Virginia | 00 | 102257717110 | 8528531774 | MULTIPOLYGON (((-75.74241 37.80835, -75.74151 ... |
| 4 | 54 | 01779805 | 0400000US54 | 54 | WV | West Virginia | 00 | 62266474513 | 489028543 | POLYGON ((-82.64320 38.16909, -82.64300 38.169... |
In [ ]:
gdf.explore()
Out[ ]:
Make this Notebook Trusted to load map: File -> Trust Notebook